package com.losdun.product.domain.vo;

import lombok.Data;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @author sword.ye
 * @date 2025/6/7
 **/
@Data
public class ProductPriceVo {
    private String customerName;
    private String productName;
    private Long productId;
    private String productImage;
    private String productCategoryName;
    private BigDecimal doorArea;
    private BigDecimal doorPrice=BigDecimal.ZERO;
    private BigDecimal doorUnitPrice;
    private String doorUnit;

    //颜色名称
    private String colorName;
    //颜色费用
    private BigDecimal colorPrice=BigDecimal.ZERO;
    //开门方式
    private String openType;

    private List<PartsPrice> partsPriceList=new ArrayList<>();

    public BigDecimal getTotalPrice() {
        return this.getPartsTotalPrice().add(doorPrice).add(colorPrice);
    }

    public BigDecimal getPartsTotalPrice() {
        return partsPriceList.stream().filter(t -> t.getTotalPrice() != null).map(PartsPrice::getTotalPrice).reduce(BigDecimal.ZERO, BigDecimal::add);

    }

    @Data
    public static class PartsPrice{
        private String configName;
        private Long configId;
        private BigDecimal totalPrice;
        private List<PartsPriceDetail> partsDetailList=new ArrayList<>();

    }
    @Data
    public static class PartsPriceDetail{
        private String text; //名称
        private Long value; //id
        private BigDecimal width;//米数
        private Integer number;//数量
        private BigDecimal price;
        private BigDecimal unitPrice;
        private String unit;
        private String remark;
    }


}
